/**
 * 
 */
package com.qb.mobile.util;

import android.content.Context;
import android.content.SharedPreferences;

import com.qb.Contants;

/**
 * @author <a href="mailto:dangcongthanhtrung@gmail.com">dangtrung</a>
 * 
 * PreferenceUtils.java class
 *
 */
public class PreferenceUtils {
	
	public final static int MODE_PRIVATE = 0;
	
	/**
	 * @param context
	 * @param key
	 * @param s
	 */
	public static void setPrefeByClear(Context context,String key, String s){
		SharedPreferences settings = context.getSharedPreferences(Contants.PREFS_NAME, MODE_PRIVATE);
	    settings.edit().clear().commit();
	    settings.edit().remove(key).commit();
		settings.edit().putString(key, s).commit();
	}
	
	/**
	 * @param context
	 * @param key
	 * @return
	 */
	public static String getPrefeByClear(Context context,String key){
		SharedPreferences settings = context.getSharedPreferences( Contants.PREFS_NAME, MODE_PRIVATE );
		String values = settings.getString(key, "");
		settings.edit().clear().commit();
		settings.edit().remove(key).commit();
		return values;
	}
}
